<template>
  <el-autocomplete
    v-model="formData[infos.en]"
    :disabled="infos.disabled"
    :fetch-suggestions="querySearch"
    :placeholder="'请输入'+infos.cn"
    class="inline-input"
  />
</template>

<script>
export default {
  name: 'Autocomplete',
  props: {
    infos: {
      type: Object,
      default: () => { return [] }
    },
    formData: {
      type: Object,
      default: () => { return [] }
    }
  },
  methods: {
    // 筛选付款银行
    querySearch(queryString, cb) {
      const list = this.infos.list
      const results = queryString ? list.filter(this.createFilter(queryString)) : list
      // 调用 callback 返回建议列表的数据
      cb(results)
    },
    createFilter(queryString) {
      return (searchKey) => {
        return (searchKey.value.toLowerCase().indexOf(queryString.toLowerCase()) === 0)
      }
    }
  }
}
</script>

